package com.fhz.shop.ui.cart;

import androidx.lifecycle.LiveData;

import com.fhz.shop.callback.ApiResponse;
import com.fhz.shop.entity.UserCart;
import com.fhz.shop.ui.cart.datasource.CartLocalDataSource;
import com.fhz.shop.ui.cart.datasource.CartRemoteDataSource;

import java.util.List;

import javax.inject.Inject;

/**
 * 时间:2023/8/30
 *
 * @author Mr.Feng
 * 简述: TODO
 */
public class CartRepository {
    @Inject
    CartLocalDataSource mCartLocalDataSource;
    @Inject
    CartRemoteDataSource mCartRemoteDataSource;

    @Inject
    public CartRepository(CartLocalDataSource cartLocalDataSource, CartRemoteDataSource cartRemoteDataSource) {
        mCartLocalDataSource = cartLocalDataSource;
        mCartRemoteDataSource = cartRemoteDataSource;
    }

    public LiveData<ApiResponse<List<UserCart>>> getCartList(int userId){
        return mCartRemoteDataSource.getCartList(userId);
    }

    public LiveData<ApiResponse<UserCart>> updateNum(int cartId ,int num){
        return mCartRemoteDataSource.updateNum(cartId, num);
    }
}
